$(function() {
	var token = localStorage.phone;
    $.ajax({
        url: 'https://newapp.icandrive.cn/api/student_me.php',
        type: 'post',
        dataType: 'json',
        data: {
            token: token
        },
        success: function(data) {
            /*console.log(data);*/
            if(data.status == 200) {
                $(data.list).each(function() {
                    $('.signature h1').html(this.user_name);
                    $('.photo').attr('src', this.photo);
                })
            }

            if(data.status == 400) {
                layer.msg("您还未实名认证哟！");
                /*setInterval(function () {
					window.location.href = "../info/information.html"
				}, 2000)*/
            }
        },
        error: function() {
            layer.msg('系统繁忙', function() {
                history.go(0)
            }, 1000);
        }
    });
    var token=localStorage.phone;
    $.ajax({
        url:'https://newapp.icandrive.cn/api/photo.php',
        dataType:'json',
        type:'post',
        success: function (data) {
            if(data.status==200){
                $(data.data).each(function () {
                    $('.left-header img').attr('src',this.teacher_photo);
                    $('.username h3').html(this.teacher_name);
                    $('#signature').val(this.autograph);
                    localStorage.place1=(this.subject2_place);
                    localStorage.place2=(this.subject3_place);
                });

            }
        }
    })

    $("#songkao").click(function() {
        var token = localStorage.phone;
        $.ajax({
            url: 'https://newapp.icandrive.cn/api/checkorder.php',
            type: 'post',
            dataType: 'json',
            data: {
                token: token
            },
            success: function(data) {
                if(data.status == 200) {

                    window.location.href = "../send/send-test.html";

                } else if(data.status == 300) {
                    layer.msg('还未约考，无法送考预约');
                } else if(data.status == 400) {
                    layer.msg("该校暂不支持送考预约");
                }
            },
            error: function() {
                layer.msg('系统繁忙');
            }
        })
    });

    $("#info").click(function() {

        var token = localStorage.phone;
        $.ajax({
            url: "https://newapp.icandrive.cn/api/realName.php",
            type: 'post',
            data: {
                token: token
            },
            dataType: 'json',
            success: function(data) {
                if(data.status == 200) {

                    layer.msg('你已实名认证过了');
                }
                if(data.status == 250) {
                    layer.msg("请重新登录");
                    setInterval(function() {
                        window.location.href = "../login/log_in.html";
                    }, 2000)
                }
                if(data.status == 400) {
                    window.location.href = "../info/information.html";
                }
            },
            error: function() {
                layer.msg('系统繁忙', function() {
                    history.go(0)
                }, 1000);
            }
        });

    });

    $("#coach").click(function() {
        window.location.href = "../info/coach_register.html";
    });
    $('.footer_list_num2').click(function() {
        window.location.href = '../studentorder/oder.html';
    })

});
/*获取登录存储的phone*/
var token = localStorage.phone;



$("#sign").click(function() {
    var token = localStorage.phone;
    $.ajax({
        url: 'https://newapp.icandrive.cn/api/school.php',
        type: 'post',
        dataType: 'json',
        data: {
            token: token
        },
        success: function(data) {
            if(data.status == 250) {
                lay.msg("请重新登陆");
                setInterval(function() {
                    window.location.href = "../login/log_in.html";
                }, 2000);
            }
            if(data.status == 200) {
                window.location.href = "../mytest/sign_up.html";
            }
            if(data.status == 400) {
                layer.msg("你还没有报名哟");
            }
        },
        error: function() {
            layer.msg('系统繁忙', function() {
                history.go(0)
            }, 1000);
        }

    });
});




/*注销按钮*/
$("#xxxxx").click(function() {
    /*alert(1);*/
    localStorage.removeItem("savalogintooken");
    localStorage.removeItem('phone');
    window.location.href = "../login/log_in.html";

});


/*监听手机返回按键*/
 return_keybord();
